package com.tanqing.ddd.domain.command;

import com.tanqing.ddd.domain.aggregate.Parkting;
import com.tanqing.ddd.domain.event.EventQueue;
import com.tanqing.ddd.domain.repository.ParktingRepository;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

@Component
public class CheckOutCommandHandle {

    @Resource
    private ParktingRepository parktingRepository;

    public boolean hadnle(EventQueue eventQueue, CheckOutCommand command){
        Parkting parkting = parktingRepository.fundByPlate(command.getPlate());
        boolean handle = parkting.handle(eventQueue, command);
        parktingRepository.save(parkting);
        return  handle;
    }
}
